package cn.dd.crmweb.modules.discern.collect.controller;


import cn.dd.crmweb.common.Result;
import cn.dd.crmweb.modules.discern.collect.entity.ColType;
import cn.dd.crmweb.modules.discern.collect.mapper.ColTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tbb
 * @since 2023-05-03
 */
@RestController
@RequestMapping("/collect")
public class ColTypeController {

    @Autowired
    private ColTypeMapper colTypeMapper;

    @GetMapping("/get/type")
    public Result getCollectType(){
        return Result.success(colTypeMapper.selectList(null));
    }
    @PostMapping("/insert/type")
    public Result insertCollectType(@RequestBody Map<String,Object> map){
        System.out.println(map.get("name"));
        ColType colType = new ColType();
        colType.setName((String) map.get("name"));
        colTypeMapper.insert(colType);
        return Result.success();
    }

    @GetMapping("/delete/type")
    public Result deleteCollectType(@RequestParam String cid){
//        System.out.println(cid);
        colTypeMapper.deleteById(cid);
        return Result.success();
    }
}

